<div [@routerTransition]>
  <div class="m-subheader">
    <div class="d-flex align-items-center">
      <div class="mr-auto col-xs-6">
        <h3 class="m-subheader__title m-subheader__title--separator">
          <span>原材料准备</span>
        </h3>
        <span class="m-section__sub"> 管理原材料准备的文本头信息 </span>
      </div>
      <div class="col-xs-6 text-right"></div>
    </div>
  </div>
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile">
      <div class="m-portlet__body">
        <div class="tabbable-line">
          <div style="width: 200px; display: inline-block; margin-bottom: 10px">
            <p-calendar
              [(ngModel)]="planDate"
              view="month"
              dateFormat="yy-mm"
              [showIcon]="true"
              name="planDate"
              [inputStyle]="{ width: '126px' }"
            ></p-calendar>
          </div>
          <div class="tab-content" style="padding-top: 0">
            <div class="tab-pane active" id="tab-model">
              <form class="horizontal-form" autocomplete="off">
                <div class="m-form m-form--label-align-right">
                  <div class="row align-items-center m--margin-bottom-10">
                    <div class="col-xl-12">
                      <div class="form-group m-form__group align-items-center">
                        <div class="input-group">
                          <input
                            [(ngModel)]="filterText"
                            name="filterText"
                            autofocus
                            class="form-control m-input"
                            [placeholder]="l('SearchWithThreeDot')"
                            type="text"
                          />
                          <span class="input-group-btn">
                            <button
                              (click)="getMonths()"
                              class="btn btn-primary"
                              type="submit"
                            >
                              <i
                                class="flaticon-search-1"
                                [attr.aria-label]="l('Search')"
                              ></i>
                            </button>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div
                    class="row margin-bottom-10"
                    *ngIf="advancedFiltersAreShown"
                  >
                    <div class="col-sm-12 text-right">
                      <button class="btn btn-metal" (click)="getMonths()">
                        <i class="fa fa-refresh"></i> {{ l("Refresh") }}
                      </button>
                    </div>
                  </div>
                  <div class="row margin-bottom-10">
                    <div class="col-sm-12">
                      <span
                        class="clickable-item text-muted"
                        *ngIf="!advancedFiltersAreShown"
                        (click)="
                          advancedFiltersAreShown = !advancedFiltersAreShown
                        "
                      >
                        <i class="fa fa-angle-down"></i>
                        {{ l("ShowAdvancedFilters") }}</span
                      >
                      <span
                        class="clickable-item text-muted"
                        *ngIf="advancedFiltersAreShown"
                        (click)="
                          advancedFiltersAreShown = !advancedFiltersAreShown
                        "
                      >
                        <i class="fa fa-angle-up"></i>
                        {{ l("HideAdvancedFilters") }}</span
                      >
                    </div>
                  </div>
                </div>
              </form>

              <div class="row align-items-center">
                <div
                  class="primeng-datatable-container"
                  [busyIf]="primengTableHelper.isLoading"
                >
                  <p-table
                    #dataTable
                    (onLazyLoad)="getMonths($event)"
                    [value]="primengTableHelper.records"
                    rows="{{ primengTableHelper.defaultRecordsCountPerPage }}"
                    [paginator]="false"
                    [lazy]="true"
                    emptyMessage="没有数据"
                    scrollable="true"
                    ScrollWidth="100%"
                    responsive="primengTableHelper.isResponsive"
                    resizableColumns="primengTableHelper.resizableColumns"
                    class="toolready"
                  >
                    <ng-template pTemplate="header">
                      <tr>
                        <th style="width: 100px">操作</th>
                        <th style="width: 100px" pSortableColumn="taskCode">
                          任务号
                          <p-sortIcon field="taskCode"></p-sortIcon>
                        </th>
                        <th style="width: 100px" pSortableColumn="taskName">
                          名称
                          <p-sortIcon field="taskName"></p-sortIcon>
                        </th>
                        <th style="width: 100px" pSortableColumn="drawingCode">
                          图号
                          <p-sortIcon field="drawingCode"></p-sortIcon>
                        </th>
                        <th style="width: 80px" pSortableColumn="monthPlanType">
                          任务类型
                          <p-sortIcon field="monthPlanType"></p-sortIcon>
                        </th>
                        <th style="width: 100px" pSortableColumn="materialName">
                          材料名称
                          <p-sortIcon field="materialName"></p-sortIcon>
                        </th>
                        <th style="width: 80px" pSortableColumn="size">
                          尺寸
                          <p-sortIcon field="size"></p-sortIcon>
                        </th>
                        <th style="width: 80px" pSortableColumn="paiHao">
                          牌号
                          <p-sortIcon field="paiHao"></p-sortIcon>
                        </th>
                        <th style="width: 80px" pSortableColumn="materialState">
                          库存状态
                          <!-- <p-sortIcon field="toolingState"></p-sortIcon> -->
                        </th>
                        <th style="width: 100px" pSortableColumn="amount">
                          任务计划数量
                          <p-sortIcon field="amount"></p-sortIcon>
                        </th>
                        <th
                          style="width: 100px"
                          pSortableColumn="amountPlanned"
                        >
                          任务投产数量
                          <p-sortIcon field="amountPlanned"></p-sortIcon>
                        </th>
                        <th style="width: 100px" pSortableColumn="dueDate">
                          计划时间
                          <p-sortIcon field="dueDate"></p-sortIcon>
                        </th>
                        <th style="width: 100px" pSortableColumn="remark">
                          备注
                        </th>
                      </tr>
                    </ng-template>
                    <ng-template
                      pTemplate="body"
                      let-record
                      let-expanded="expanded"
                    >
                      <tr>
                        <td style="width: 100px">
                          <div
                            class="btn-group dropdown"
                            dropdown
                            container="body"
                          >
                            <button
                              dropdownToggle
                              class="dropdown-toggle btn btn-sm btn-primary"
                            >
                              <i class="fa fa-cog"></i
                              ><span class="caret"></span>
                              操作
                            </button>
                            <ul class="dropdown-menu" *dropdownMenu>
                              <li *ngIf="isGranted('Pages.Maintasks.PutInto')">
                                <a
                                  (click)="
                                    setWorkshopremark.show(
                                      record.id,
                                      record.remark,
                                      3,
                                      $event
                                    )
                                  "
                                  >录入备注</a
                                >
                              </li>
                            </ul>
                          </div>
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 任务号</span>
                          {{ record.taskCode }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 名称</span>
                          {{ record.taskName }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 图号</span>
                          {{ record.drawingCode }}
                        </td>
                        <td style="width: 80px">
                          <span class="ui-column-title"> 任务类型</span>
                          {{ record.monthPlanType }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 材料名称</span>
                          {{ record.materialName }}
                        </td>
                        <td style="width: 80px">
                          <span class="ui-column-title"> 尺寸</span>
                          {{ record.size }}
                        </td>
                        <td style="width: 80px">
                          <span class="ui-column-title"> 牌号</span>
                          {{ record.paiHao }}
                        </td>
                        <td style="width: 80px">
                          <span class="ui-column-title"> 库存状态</span>
                          <span>
                            <span
                              style="color: red; display: block"
                              *ngIf="record.MaterialState != true"
                              >缺料</span
                            >
                            <span
                              style="color: green; display: block"
                              *ngIf="record.MaterialState == true"
                              >库存：{{ record.materialNum }}</span
                            >
                          </span>
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 任务计划数量</span>
                          {{ record.amount }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 任务投产数量</span>
                          {{ record.amountPlanned }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 计划时间</span>
                          {{ record.dueDate | momentFormat: "YYYY-MM-DD" }}
                        </td>
                        <td style="width: 100px">
                          <span class="ui-column-title"> 备注</span>
                          {{ record.remark }}
                        </td>
                      </tr>
                    </ng-template>
                  </p-table>
                  <div class="primeng-paging-container">
                    <p-paginator
                      rows="{{ primengTableHelper.defaultRecordsCountPerPage }}"
                      #paginator
                      (onPageChange)="getMonths($event)"
                      [totalRecords]="primengTableHelper.totalRecordsCount"
                      [rowsPerPageOptions]="
                        primengTableHelper.predefinedRecordsCountPerPage
                      "
                    >
                    </p-paginator>
                    <span class="total-records-count">
                      {{ "总计:" + primengTableHelper.totalRecordsCount }}
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <setWorkshopremark
    #setWorkshopremark
    (modalSave)="getMonths($event)"
  ></setWorkshopremark>
</div>
